package com.fc.test.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.fc.test.common.base.BaseService;
import com.fc.test.common.support.Convert;
import com.fc.test.mapper.auto.TAbbTousuMapper;
import com.fc.test.model.auto.TAbbTousu;
import com.fc.test.model.auto.TAbbTousuExample;
import com.fc.test.model.custom.Tablepar;
import com.fc.test.util.SnowflakeIdWorker;

/**
 * Service
* @Title: TAbbTousuService.java 
* @Package com.fc.test.entity 
* @author fuce
* @email 87766867@qq.com
* @date 2019-08-22 18:34:02  
 */
@Service
public class TAbbTousuService implements BaseService<TAbbTousu, TAbbTousuExample>{
	@Autowired
	private TAbbTousuMapper tAbbTousuMapper;

	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<TAbbTousu> list(Tablepar tablepar,String name,String id,String goodid){
	        TAbbTousuExample testExample=new TAbbTousuExample();
	        testExample.setOrderByClause("id ASC");
		 TAbbTousuExample.Criteria criteria=testExample.createCriteria();
			 if(id!=null&&!"".equals(id)){
				 criteria.andGoodsidEqualTo(id);
			 }else{
				 criteria.andGoodsidEqualTo(goodid);
			 }
	    	if(name!=null&&!"".equals(name)){
			criteria.andUsernameLike("%"+name+"%");
	    	}
	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<TAbbTousu> list= tAbbTousuMapper.selectByExample(testExample);
	        PageInfo<TAbbTousu> pageInfo = new PageInfo<TAbbTousu>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
		List<String> lista=Convert.toListStrArray(ids);
		TAbbTousuExample example=new TAbbTousuExample();
		example.createCriteria().andIdIn(lista);
		return tAbbTousuMapper.deleteByExample(example);
	}


	@Override
	public TAbbTousu selectByPrimaryKey(String id) {

		return tAbbTousuMapper.selectByPrimaryKey(id);
	}


	@Override
	public int updateByPrimaryKeySelective(TAbbTousu record) {
		return tAbbTousuMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 添加
	 */
	@Override
	public int insertSelective(TAbbTousu record) {
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
		return tAbbTousuMapper.insertSelective(record);
	}










	@Override
	public int updateByExampleSelective(TAbbTousu record, TAbbTousuExample example) {

		return tAbbTousuMapper.updateByExampleSelective(record, example);
	}


	@Override
	public int updateByExample(TAbbTousu record, TAbbTousuExample example) {

		return tAbbTousuMapper.updateByExample(record, example);
	}

	@Override
	public List<TAbbTousu> selectByExample(TAbbTousuExample example) {

		return tAbbTousuMapper.selectByExample(example);
	}


	@Override
	public long countByExample(TAbbTousuExample example) {

		return tAbbTousuMapper.countByExample(example);
	}


	@Override
	public int deleteByExample(TAbbTousuExample example) {

		return tAbbTousuMapper.deleteByExample(example);
	}


}
